/**
 * KAYO APPLIANCE CHAINS.
 * Copyright (c) 2016-2016 All Rights Reserved.
 */
package com.leku.mse.dao.impl.member;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.leku.commons.datasource.DataSourceClient;
import com.leku.mse.dao.member.MemberDao;
import com.leku.mse.entity.DynamicEntity;
import com.leku.mse.entity.MemScoreEntity;
import com.leku.mse.entity.MemberEntity;

/**
 * 功能描述: 会员数据操作
 *
 * @author suiying
 * @created 2017年5月16日
 * @version 1.0.0
 */
@Repository
public class MemberDaoImpl implements MemberDao {

    @Autowired
    private DataSourceClient dataSourceClient;

    /*
     * (non-Javadoc)
     * @see com.leku.memcenter.dao.member.MemberManageDao#insertMember(com.leku.memcenter.entity.MemberEntity)
     */
    @Override
    public int insertMember(MemberEntity member) {

        dataSourceClient.update("dbBaseDao.setCharset");

        return dataSourceClient.insert("memberManageDao.insertMember", member);
    }

    /*
     * (non-Javadoc)
     * @see com.leku.memcenter.dao.member.MemberManageDao#updateMember(com.leku.memcenter.entity.MemberEntity)
     */
    @Override
    public int updateMember(MemberEntity member) {

        dataSourceClient.update("dbBaseDao.setCharset");

        return dataSourceClient.update("memberManageDao.updateMember", member);
    }

    /*
     * (non-Javadoc)
     * @see com.leku.memcenter.dao.member.MemberManageDao#insertMemberDynamic(com.leku.memcenter.entity.DynamicEntity)
     */
    @Override
    public int insertMemberDynamic(DynamicEntity dynamic) {

        return dataSourceClient.insert("memberManageDao.insertMemberDynamic", dynamic);
    }

    /*
     * (non-Javadoc)
     * @see com.leku.memcenter.dao.member.MemberManageDao#updateMemberBase(com.leku.memcenter.entity.MemberEntity)
     */
    @Override
    public int updateMemberBase(MemberEntity member) {
        dataSourceClient.update("dbBaseDao.setCharset");

        return dataSourceClient.update("memberManageDao.updateMemberBase", member);
    }

    /*
     * (non-Javadoc)
     * @see com.leku.mse.dao.member.MemberDao#insertMemScore(com.leku.mse.entity.MemScoreEntity)
     */
    @Override
    public int insertMemScore(MemScoreEntity score) {

        return dataSourceClient.insert("memberManageDao.insertMemScore", score);
    }

    /*
     * (non-Javadoc)
     * @see com.leku.mse.dao.member.MemberDao#getMember(java.lang.String)
     */
    @Override
    public MemberEntity getMember(String memberCode) {
        Map<String, Object> param = new HashMap<String, Object>();

        param.put("memberCode", memberCode);

        return dataSourceClient.selectOne("memberManageDao.getMember", param);
    }

}
